#include <bits/stdc++.h>

using namespace std;
#define int long long
const int inf = 0x3f3f3f3f3f3f3f3f;

void solve()
{
    int a, b;
    cin >> a >> b;
    int x = max(a, b) * max(a, b) - min(a, b) * min(a, b);
    int ans = 3;
    if (x == 3) cout << 1 << endl;
    else if (x == 5) cout << 2 << endl;
    else
    {
        if ((x - 3) % 4 == 0) cout << (x - 3) / 4 * 3 << endl;
        else if ((x - 3) % 4 == 1) cout << (x - 4) / 4 * 3 + 1 << endl;
        else cout << (x - 5) / 4 * 3 + 2 << endl;
    }
}

signed main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
    int t = 1;
    cin >> t;
    while (t--)
    {
        solve();
    }
    return 0;
}